package model;

import static org.junit.Assert.*;

import org.junit.Test;

public class PackageTest {

  @Test
  public void packageWithClass() {
    SysPackage p = new SysPackage("package");
    SysClass A = new SysClass("A");
    p.add(A);
    assertTrue(p.contains(A));
  }

  @Test
  public void packageWithoutClass() {
    SysPackage p = new SysPackage("package");
    SysClass B = new SysClass("B");
    assertFalse(p.contains(B));
  }

  @Test
  public void twoInstancesRepresentingSameClass() {
    SysPackage p = new SysPackage("package");
    SysClass A = new SysClass("A");
    SysClass B = new SysClass("A");
    B.setOwner(p);
    p.add(A);
    assertTrue(p.contains(B)); //uses the fully qualified name
  }

//  @Test     //not applicable test
//  public void twoInstancesRepresentingSameClassUpperCaserAndDownCase() {
//    SysPackage p = new SysPackage("package");
//    SysClass A = new SysClass("A");
//    SysClass B = new SysClass("a");
//    B.setOwner(p);
//    p.add(A);
//    assertTrue(p.contains(B));//uses the fully qualified name
//  }

  /*
   * Now working with package within package
   */

  @Test
  public void packageWithinPackage() {
    SysPackage inner = new SysPackage("inner");
    SysPackage outter = new SysPackage("outter");
    outter.add(inner);
    assertTrue(outter.contains(inner));
  }

  @Test
  public void packageWithinPackageDifferentInstances() {
    SysPackage inner = new SysPackage("inner");
    SysPackage different = new SysPackage("inner");
    SysPackage outter = new SysPackage("outter");
    outter.add(inner);
    assertTrue(outter.contains(different));
  }

  @Test
  public void packageWithoutPackage() {
    SysPackage shouldBeInner = new SysPackage("inner");
    SysPackage outter = new SysPackage("outter");
    assertFalse(outter.contains(shouldBeInner));
  }

  @Test
  public void samePackageUpperCaseDownCase() {
    SysPackage upperCase = new SysPackage("packAge");
    SysPackage downCase = new SysPackage("package");
    assertTrue(upperCase.equalsIgnoreFullyQualifiedName(downCase));
  }
  
  @Test
  public void differentFullyQualifiedName() {
    SysPackage p = new SysPackage("package");
    SysPackage q = new SysPackage("package");
    p.setOwner(q);
    assertFalse(p.equals(q));
  }
  
  @Test
  public void sameFullyQualifiedName() {
    SysPackage aplication = new SysPackage("SysGraph4AJ");
    SysPackage aplication1 = new SysPackage("SysGraph4AJ");

    SysPackage p = new SysPackage("model");
    SysPackage q = new SysPackage("model");
    aplication.add(q);
    aplication1.add(p);
    assertTrue(p.equals(q));
  }
  
  @Test
  public void hasAspect(){
  	SysPackage pack = new SysPackage("package");
  	SysAspect aspect = new SysAspect("Aspecto1");
  	SysAspect aspect1 = new SysAspect("Aspecto1");
  	pack.add(aspect1);
  	assertTrue(pack.contains(aspect));
  	assertTrue(pack.getAspects().size()==1);
  }
  
  
  
  
  
  
  

}
